$(function() {

	var id = getQueryString("id");
	// 1是评价，0是破损上报
	var tp = getQueryString("tp");

	
	
	$("#to_sub").click(function(){
		if(tp==1){
			submitPingjia(id);
		}else if(tp==2){
			submitYuyue(id);
		}
	});
	
	function submitPingjia(id) {
		var evaluationStar = $("#evaluationStar").text();
		var content = $("#RD_textarea").val();
		if ($(this).children("i").hasClass("anonymity")) {
			openid = "";
		}
		
		$.post({
					url : baseUrl + 'api/book/bookEvaluation/create',
					data : JSON.stringify({
						bid : id,
						openid: openid,
						evaluationContent: content,
						evaluationStar: evaluationStar
					}),
					contentType: "application/json",
					success : function(data) {
						var data = data.data;
						alert("评价成功！");
					}
				});
	}

	function showPingfen(id) {
		$.get({
					url : baseUrl + 'api/book/bookEvaluation/findPage',
					data : {
						id : id,
						pageNum : 1,
						pageSize : 10
					},
					success : function(data) {
						var data = data.data.list;
						$("#Details_list").empty();
						var htmlOutput = $.templates("#book_evaluation_tmpl")
								.render(data);
						$("#Details_list").html(htmlOutput);
					}
				});
	}
})